package com.example.demo1105.demo1;

import java.util.Arrays;
import java.util.Optional;
/**
 * @Author: FBS
 * @Description: TODO
 * @DateTime: 2022/11/5 15:13
 *@Version:1.0
 */
public class Test02 {
    public static void main(String[] args) {
        Integer[] arr ={6,5,2,4,3,8};
        Optional<Integer> reduce = Arrays.stream(arr).reduce((t1, t2) -> t1 += t2);
        System.out.println(reduce);

        Optional<Integer> max = Arrays.stream(arr).reduce((t1, t2) -> t1>t2?t1:t2);
        System.out.println(max);

        Optional<Integer> min = Arrays.stream(arr).reduce((t1, t2) -> t1<t2?t1:t2);
        System.out.println(min);
    }
}
